<form class="dark_form" method="post" action="<?php echo $action ?>">
    <h2>Registration</h2>
    <div class="field">
        <div class="ilabel">Name</div>
        <div class="iinput">
            <input type="text" class="itext" id="name" name="name" value="<?php echo $user->name; ?>" onchange="validateName()"/>
            <div class="ireq">Min. 5 characters, only space and alphabet.</div>
        </div>
        <div class="iinfo" id="nama_info"></div>
    </div>
    <?php if($show_username == TRUE) : ?>
    <div class="field">
        <div class="ilabel">Username</div>
        <div class="iinput">
            <input type="text" class="itext" id="uname" name="username" value="<?php echo $user->username; ?>" onchange="validateUname()"/>
            <div class="ireq">Min. 5 characters, Alphanumeric and dot ('.').</div>
        </div>
        <div class="iinfo" id="uname_info"></div>
    </div>
    <?php endif;?>
    <div class="field">
        <div class="ilabel">Password</div>
        <div class="iinput">
            <input type="password" class="itext" id="pw" name="password" onchange="validatePw()"/>
            <div class="ireq">Min. 6 characters.</div>
        </div>
        <div class="iinfo" id="pw_info"></div>
    </div>
    <div class="field">
        <div class="ilabel">Re-type password</div>
        <div class="iinput">
            <input type="password" class="itext" id="pwa" onchange="validatePwa()"/>
            <div class="ireq">Must be equal to Password.</div>
        </div>
        <div class="iinfo" id="pwa_info"></div>
    </div>
    <div class="field">
        <div class="ilabel">Birth date</div>
        <div class="iinput">
            <input type="text" class="itext" id="bd" name="birth_date" value="<?php echo $user->birth_date; ?>" onchange="validateBirthdate()"/>
            <input type="button" class="ical" onclick="openCalReg()" value="calendar"/>

            <!-- CALENDAR -->
            <div class="floatcal" id="floatcalReg">
                <script type="text/javascript">
                    //<![CDATA[
                    var calReg = new Calendar(
                        new Date(),
                        document.getElementById("floatcalReg"),
                        "calReg",
                        function(date){
                            var yyyy = "" + date.getFullYear();
                            while(yyyy.length < 4) yyyy = "0" + yyyy;
                            var mm = "" + (date.getMonth() + 1);
                            while(mm.length < 2) mm = "0" + mm;
                            var dd = "" + date.getDate();
                            while(dd.length < 2) dd = "0" + dd;
                            document.getElementById('bd').value = yyyy + "-" + mm + "-" + dd;
                            openCalReg();
                            validateBirthdate();
                        }
                    );

                    function openCalReg() {
                        if(calReg.isVisible) calReg.hideCalendar();
                        else calReg.drawCalendar();
                    }
                    //]]>
                </script>
            </div>

            <div class="ireq">YYYY-MM-DD</div>
        </div>
        <div class="iinfo" id="bd_info"></div>
    </div>
    <div class="field">
        <div class="ilabel">E-Mail</div>
        <div class="iinput">
            <input type="text" class="itext" id="email" name="email" value="<?php echo $user->email; ?>" onchange="validateEmail()"/>
            <div class="ireq">Min. 5 characters, alphanumeric and dot ('.').<br/>Top level domain should contain at least 2 characters.</div>
        </div>
        <div class="iinfo" id="email_info"></div>
    </div>
    <div class="field">
        <div class="ilabel">Gender</div>
        <div class="iinput">
            <select class="idropdown" name="gender">
                <option value="Male" <?php if($user->gender == 'Male') echo "selected" ?>>Male</option>
                <option value="Female" <?php if($user->gender == 'Female') echo "selected" ?>>Female</option>
            </select>
            <div class="ireq"></div>
        </div>
        <div class="iinfo" id="gender_info"></div>
    </div>
    <div class="field">
        <div class="ilabel">Location</div>
        <div class="iinput">
            <select name="location_id">
                <?php
                foreach ($locations as $location) :
                ?>
                <option value="<?php echo $location->id ?>" <?php if($location->id == $user->location_id) echo "selected" ?>>
                    <?php echo $location->location_name; ?>
                </option>
                <?php
                endforeach;
                ?>
            </select>
        </div>
        <div class="iinfo" id="loc_info"></div>
    </div>
    <div class="field">
        <div class="ilabel">Wall Access</div>
        <div class="iinput">
            <select name="wall_access">
                <?php
                foreach ($access as $a) :
                ?>
                <option value="<?php echo $a->id ?>" <?php if($a->id == $user->wall_access) echo "selected" ?>>
                    <?php echo $a->description; ?>
                </option>
                <?php
                endforeach;
                ?>
            </select>
        </div>
        <div class="iinfo" id="loc_info"></div>
    </div>

    <div class="subm_wrap">
        <input type="submit" class="isubmit" name="submit" onclick="return validateRegistration()" value="<?php echo $submit_value ?>"/>
    </div>
</form>

<div id ="fb-root"></div>
<script type="text/javascript">
    <?php echo $updateFacebook ?>
</script>

